DISCUSSION
The
ATSUGetGlyphBounds function returns the rotated final typographic bounds in multiple trapezoids, if needed, taking into account line rotation, flushness, and justification. It passes back the enclosing trapezoid(s) that represent the typographic glyph bounds of a range of text.
To obtain the typographic bounding rectangle around a line of text prior to line layout, call the function
ATSUMeasureText. To calculate the standard bounding rectangle around a final laid-out line, call the function
ATSUMeasureTextImage.
Before calculating the typographic glyph bounds of a range of text,
ATSUGetGlyphBounds examines the text layout object to make sure that the style runs cover the entire range of text. If there are gaps between style runs,
ATSUGetGlyphBounds assigns the characters in the gap to the style run following the gap. If there is no style run at the beginning of the range of text,
ATSUGetGlyphBounds assigns these characters to the first style run it can find. If there no style run at the end of the range of text,
ATSUGetGlyphBounds assigns the remaining characters to the last style run it can find.
The coordinates of each trapezoid are offset by the amount specified in the
iTextBasePointX and
iTextBasePointY parameters. If you want to draw the typographic bounds on the screen, pass the position of the origin of the line in the current graphics port in these parameters. This enables
ATSUGetGlyphBounds to match the trapezoids to their onscreen image.
The height of the trapezoid(s) is determined by the line ascent and descent attribute values you previously set for the line. If you have not set these values for the line,
ATSUGetGlyphBounds will use the values set for the text layout object containing the line. If neither have been set,
ATSUGetGlyphBounds will use the natural line ascent and descent calculated for the line. The width of the trapezoid(s) is determined using the caret origin, glyph origin in device space, or glyph origin in fractional absolute positions, depending upon the value you pass in the
iTypeOfBounds parameter.
You should call
ATSUGetGlyphBounds to do your own text highlighting, using the fractional origin (instead of the device origin) for the width of the highlight.